mui.init({
    // preloadPages: [
    //     {   //预加载
    //         url: 'index.html',
    //         id: 'index.html'
    //     }, {
    //         url: "dizhen.html",
    //         id: "dizhen.html"//默认使用当前页面的url作为id
    //     }
    // ]
});

//地震页面传入id

mui.plusReady(function () {
	
    var eqId= plus.webview.currentWebview().detail_id;
    $('.leaflet-echart-icon').hide();
//  var eqId="001";
    haveCenter(eqId);//中心点
    haveTitle(eqId);//标题
    getcountrys(eqId);//周边县
    gettowns(eqId);//周边乡
    getRoads(eqId);//周边道路
    getAffectedPop(eqId);//灾区人口
    getAffectedHouse(eqId);//灾区房屋
    getAssessBuilding(eqId);//灾害房屋评估
    getLocalReport(eqId); //获取地方上报灾情  
    getHistEarth(eqId);//获取历史地震
    getusgs(eqId);//usgs
    // 获取所有Webview窗口
    var wvs = plus.webview.all();
//  plus.webview.getWebviewById("dizhenzaihaizhuanti.html").show();
    for (i = 0; i < wvs.length; i++) {//写var i=0 苹果端报错？？
        if (wvs[i].id == 'yingjixiangying.html') {
            	plus.webview.hide(wvs[i]);
                plus.webview.close(wvs[i]);
            }
            if (wvs[i].id == 'dizhen.html') {
            	plus.webview.hide(wvs[i]);
            	plus.webview.close(wvs[i]);
        	}
        // console.log('webview' + i + ': ' + wvs[i].getURL());
        // console.log('webview' + i + ': ' + wvs[i].id);
    }
    
    document.getElementById("return_dizhen").addEventListener('tap', function (event) {
        mui.openWindow({
            url: 'yingjixiangying.html?dz',
            id: 'dizhen.html',
            show: {
                autoShow: true,//页面loaded事件发生后自动显示，默认为true
                aniShow: 'pop-in',
                duration: '100'
            },
            styles: {
                popGesture: 'none',
                hardwareAccelerated: true
            },
            waiting: {
                autoShow: true
            }
        });
    }, false);
    //跳转index页面
    document.getElementById("return_Index02").addEventListener('tap', function (event) {
        // 获取所有Webview窗口
        var wvs = plus.webview.all();
        var index_id=plus.webview.getLaunchWebview().id;
        for (var i = 0; i < wvs.length; i++) {
            console.log('webview' + i + ': ' + wvs[i].getURL());
            console.log('webview' + i + ': ' + wvs[i].id);
            if (wvs[i].id != index_id) {
                plus.webview.close(wvs[i]);
            }
        }
        // mui.back();
        plus.webview.getLaunchWebview().show();
    }, false);
});



//底部分类功能
var functionalClassification = $('#GongnengfenleiBtn');//地图功能分类按钮
var imgBtnType = $('#img-btn-type');//地图功能分类按钮下的img
var imgBtnType1 = $('#img-btn-type1');//灾情下拉框按钮
var CollapseHousing = $('.bottomFangwudaosun');//房屋倒损弹框
var historyEarthquake = $('.bottomLishidizhen');//历史地震
var imgType5 = $('#img-type5');//历史地震按钮
//按钮点击功能分类
var bottomGongnengfenlei = document.querySelector(".bottomGongnengfenlei");
bottomGongnengfenlei.style.display = "none";


//县 乡镇 道路 的切换
for (var n = 0; n < document.querySelectorAll('.type-control').length; n++) {
    document.querySelectorAll('.type-control')[n].addEventListener('tap', function (e) {
        var html = this.innerHTML;
        document.querySelector('.type-change').innerHTML = html;
    })
}
//按钮点击受损分类
var bottomShousunfenlei = $(".bottomShousunfenlei");
//设备高度
var deviceHeight = $(window).height();
//列表展示后，点击其他地方收起列表
var bottomHeight = bottomShousunfenlei.outerHeight();
//评估倒损列表的高
var commentHeight = CollapseHousing.outerHeight();
//历史地震列表的高度
var historyearthquake = historyEarthquake.outerHeight();
//usgu的高度
var usguHeight = deviceHeight - 84 - 42 - 230;
//paper的高度
var paperHeight = deviceHeight - 84 - 42 - 230;
//根据不同的终端尺寸确定不同的scroll尺寸
(function makesureSize() {
    $('.myscrollwrap').css({
        "height": bottomHeight - 144
    });
    $('.myscrollwrap1').css({
        "height": commentHeight - 75
    });
    $('.myscrollwrap2').css({
        "height": historyearthquake - 35
    });
    $('#usgu').css({
        "height": usguHeight
    });
    $('#paper').css({
        "height": paperHeight
    });
    $('.myscrollwrap3').css({
        "height": bottomHeight - 70
    });
})();
//历史地址绿色tr点击之后显示的模拟数据
var dataArray1 = ['2321人', '321人', "5人", "2324间", '2325万人', '58万'];
var dataArray2 = ['564人', '3人', '5人', '23224间', '235万人', '6556万'];
document.querySelector("#img-btn-type").addEventListener("touchstart", function (e) {
    //地图种类切换交互
    if (!imgBtnType.hasClass('active1')) {
        bottomGongnengfenlei.style.display = "block";
        functionalClassification.css({
            "borderColor": "#ccc",
            "background": '#fff'
        });
        imgBtnType.addClass('active1').css('backgroundPosition', "-222px -124px");
    } else {
        bottomGongnengfenlei.style.display = "none";
        functionalClassification.css({
            "borderColor": "transparent",
            "background": 'transparent'
        });
        imgBtnType.removeClass('active1').css('backgroundPosition', "-222px -82px");
    }
    bottomShousunfenlei.css({
        "bottom": '-' + bottomHeight + "px"
    });
    imgBtnType1.removeClass("active1").css('backgroundPosition', "-185px -82px");
    imgType5.removeClass("active1").css('backgroundPosition', "-185px -82px");
    historyEarthquake.css({
        "bottom": '-' + historyearthquake + "px"
    });
    e.stopPropagation();
});
var domWraper = document.querySelectorAll('.mui-scroll-wrapper');
for (var i = 0; i < domWraper.length; i++) {
    domWraper[i].addEventListener("swipedown", function (e) {
        e.stopPropagation();
    });
}
var csm = document.querySelector('body');
csm.addEventListener("swipedown", function (event) {//body上的向下滑动事件
    imgBtnType1.removeClass("active1").css('backgroundPosition', "-185px -82px");
    bottomShousunfenlei.css({
        "bottom": '-' + bottomHeight + "px"
    });
    CollapseHousing.css({
        "bottom": '-' + commentHeight + "px"
    });
    imgType5.removeClass("active1").css('backgroundPosition', "-185px -82px");
    historyEarthquake.css({
        "bottom": '-' + historyearthquake + "px"
    });
});
csm.addEventListener('touchstart', function (event) {//body上的触摸事件

    if (event.target.id == 'civilAffairs') {
        $('.civilAffairs').addClass('activebtn');
        $('.earthquakeBureau').removeClass('activebtn');
        $('.info-content').find('span').each(function (i) {
            $(this).html(dataArray1[i]);
        })
    }
    if (event.target.id == 'earthquakeBureau') {
        $('.earthquakeBureau').addClass('activebtn');
        $('.civilAffairs').removeClass('activebtn');
        $('.info-content').find('span').each(function (i) {
            $(this).html(dataArray2[i]);
        })
    }

    bottomGongnengfenlei.style.display = "none";
    functionalClassification.css({
        "borderColor": "transparent",
        "background": 'transparent'
    });
    imgBtnType.removeClass('active1').css('backgroundPosition', "-222px -82px");

    //按钮点击受损分类
    if (event.target.id == "img-btn-type1") {
        if (!imgBtnType1.hasClass("active1")) {
            imgBtnType1.addClass("active1").css('backgroundPosition', "-185px -124px");
            bottomShousunfenlei.css({
                "bottom": '0px'
            });
        } else {
            imgBtnType1.removeClass("active1").css('backgroundPosition', "-185px -82px");
            bottomShousunfenlei.css({
                "bottom": '-' + bottomHeight + "px"
            });
        }
        return;
    }
    if (imgBtnType1.hasClass("active1")) {
        var startY = event.touches[0].clientY;
        if (startY <= bottomShousunfenlei.offset().top) {
            imgBtnType1.removeClass("active1").css('backgroundPosition', "-185px -82px");
            bottomShousunfenlei.css({
                "bottom": '-' + bottomHeight + "px"
            });
        }
    }
    //点击受损评估向上按钮
    if (event.target.className == "pull-up mui-icon mui-icon-arrowup") {
        CollapseHousing.css({
            "bottom": 0 + "px"
        });
        return;
    }
    var startY = event.touches[0].clientY;
    if (startY <= CollapseHousing.offset().top) {
        CollapseHousing.css({
            "bottom": '-' + commentHeight + "px"
        });
    }
    if (event.target.id == 'img-type5') {
        if (!imgType5.hasClass("active1")) {
            imgType5.addClass("active1").css('backgroundPosition', "-185px -124px");
            historyEarthquake.css({
                "bottom": 0 + "px"
            });
        } else {
            imgType5.removeClass("active1").css('backgroundPosition', "-185px -82px");
            historyEarthquake.css({
                "bottom": '-' + historyearthquake + "px"
            });
        }
    }
    if (startY <= historyEarthquake.offset().top && event.target.id != 'img-type5') {
        imgType5.removeClass("active1").css('backgroundPosition', "-185px -82px");
        historyEarthquake.css({
            "bottom": '-' + historyearthquake + "px"
        });
    }
    return false;
});

//受损分类的滚动事件
var scrollOption = {
    scrollY: true, //是否竖向滚动
    scrollX: false, //是否横向滚动
    startX: 0, //初始化时滚动至x
    startY: 0, //初始化时滚动至y
    indicators: true, //是否显示滚动条
    deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
    bounce: false //是否启用回弹
};
mui('.mui-scroll-wrapper').scroll(scrollOption);



// document.getElementById("return_dizhen").addEventListener('tap', function (event) {
//
// //本页面是缓存页面,返回上一页面的时候没有关闭,回到本页面再次请求数据,更新chart的时候会提醒以被实例化,不能再次实例化,所以每当返回上一页的时候清除这些事例
//     //烈度图实例销毁
//     // firstChart.dispose();
//     //房屋结构图实例销毁
//     myChart.dispose();
//     //usgs1
//     myChart1.dispose();
//     //usgs2
//     myChart2.dispose();
// //					plus.webview.close(plus.webview.currentWebview())   //彻底关闭页面，即使本页面是预加载页面
// }, false);
//Openlayer  geojson   处理插件    到底部全部


//[28.60553, 104.17871],
var map = new L.map('bg', {
    center: [28.60553, 104.17871],
    zoom: 7
});
function cleardblclick(e) {
	return false;
}
map.on('dblclick',cleardblclick);
//所有图层先声明，以防止数据未接收而报错
if (map.tap) map.tap.disable();//消除单击地图放大的功能

// .以marker形式添加Echarts在map
var pictures = L.marker([31.228753, 121.479802], {
    icon: L.divIcon({
        className: 'leaflet-demo-icon', 
        iconSize: [160, 160],
        html: ''
    })
}).addTo(map);
new L.marker([31.228753, 121.479802], {
    icon: L.divIcon({
        className: 'leaflet-demo-icon',
        iconSize: [25, 41],
        html: ''
    })
}).addTo(map);
//var marker1 = new L.marker([31.221515, 121.481428]);
//var marker2 = new L.marker([23.071932, 113.219245]);
//var totalLayer1 = L.layerGroup([marker1, marker2]);

// new L.marker([23.071932, 113.219245]).on('click', function (e) {
//     console.log(2323)
// }).addTo(map);
// new L.marker([43.918961, 87.597538]).on('click', function (e) {
//     console.log(2323)
// }).addTo(map);
// new L.marker([47.385302, 123.932747]).on('click', function (e) {
//     console.log(2323)
// }).addTo(map);
// new L.marker([29.622349, 91.050216]).on('click', function (e) {
//     console.log(2323)
// }).addTo(map);

var normalm = L.tileLayer.chinaProvider('GaoDe.Normal.Map', {
        maxZoom: 14,
        minZoom: 3
    }),
    imgm = L.tileLayer.chinaProvider('GaoDe.Satellite.Map', {
        maxZoom: 14,
        minZoom: 3
    }),
    imga = L.tileLayer.chinaProvider('GaoDe.Satellite.Annotion', {
        maxZoom: 14,
        minZoom: 3
    }),
    term = L.tileLayer.chinaProvider('TianDiTu.Terrain.Map', {
        maxZoom: 14,
        minZoom: 3
    }),
    tera = L.tileLayer.chinaProvider('TianDiTu.Terrain.Annotion', {
        maxZoom: 14,
        minZoom: 3
    });

var vec_c = L.layerGroup([normalm]),
    img_c = L.layerGroup([imgm, imga]),
    ter_c = L.layerGroup([term, tera]);
vec_c.addTo(map);


//L.marker([39.9788, 116.30226]).addTo(map)
//  .bindPopup('A pretty CSS3 popup.<br> Easily customizable.');
//        .openPopup();
//    var geojsonFeature = {
//        "type": "Feature",
//        "properties": {
//            "name": "Coors Field",
//            "amenity": "Baseball Stadium",
//            "popupContent": "This is where the Rockies play!"
//        },
//        "geometry": {
//            "type": "Point",
//            "coordinates": [51.505, -0.09]
//        }
//    };
//    $.get('data/mapdata/china.json',function (data) {
//        console.log(data);
//    });
var position1 = [//绿色圆位置
    [37.93553, 78.84888],
    [36.89719, 78.22266]
];

var circleStyle1 = {
    radius: 10000,
    "fillColor": "green",
    "opacity": 1,
    "color": "blue",
    fillOpacity: 1,
    weight: 0
};
var circleLayers1 = [];
//添加绿色圆
for (var i = 0; i < 2; i++) {
    (function (i) {
        var circleLayer = L.circle(position1[i], circleStyle1);
        circleLayers1.push(circleLayer);
        circleLayer.on('click', function (e) {
            var popup = L.popup()
                .setLatLng(e.latlng)
                .setContent('<p>人口统计' + (i + 1) + e.latlng + '</p>')
                .openOn(map);
        });
    })(i)
}
//创建图层组
//var totalLayer= L.layerGroup(circleLayers1).addTo(map);//绿色圆

// var circleLayers = [];
// var position = [//黄色圆位置
//     [38.45359, 77.73926],
//     [37.11653, 77.56897],
//     [37.37016, 79.00269]
// ];
// var circleStyle = {
//     radius: 10000,
//     "fillColor": "yellow",
//     "opacity": 1,
//     "color": "blue"
// };
// //添加黄色圆
// for (var i = 0; i < 3; i++) {
//     (function (i) {
//         var circleLayer = L.circle(position[i], circleStyle);
//         circleLayers.push(circleLayer);
//         circleLayer.on('click', function (e) {
//             var popup = L.popup()
//                 .setLatLng(e.latlng)
//                 .setContent('<p>受灾情况' + (i + 1) + e.latlng + '</p>')
//                 .openOn(map);
//         });
//     })(i)
// }
//
// //创建一个图层组
// var totalLayer = L.layerGroup(circleLayers);//黄色圆



var geojson, info, legend;//人口密度图的图层和图例

//防止人口密度数据未接收到，程序报错
(function keepSafePopulation() {
    info = L.control({position: 'topright'});//添加一个组件，也可以使用自己定义的组件，设置监听事件，使用float属性 或者position:absolute

    info.onAdd = function (mymap) {
        this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
        this.update();
        return this._div;
    };

// method that we will use to update the control based on feature properties passed
    info.update = function (props) {
        this._div.innerHTML = '<h4>China Population Density</h4>';
    };

// info.addTo(map);//加入图标

    legend = L.control({position: 'bottomright'});

    legend.onAdd = function (map) {//onAdd函数向其中添加组件

        var div = L.DomUtil.create('div', 'info legend'),
            grades = [0, 10, 50, 100, 200, 500, 1000, 3000],
            labels = [];

        // loop through our density intervals and generate a label with a colored square for each interval
        div.innerHTML = '<h4>China Population Density</h4>';
        return div;
    };
// legend.addTo(map);//加入显示比例尺
})();

// $.get('data/mapdata/china.json', function (data) {//请求geoJson数据
var chinaData = china;

function getColor(d) {//#800026
    return d > 3000 ? '#800026' :
        d > 1000 ? '#BD0026' :
            d > 500 ? '#E31A1C' :
                d > 200 ? '#FC4E2A' :
                    d > 100 ? '#FD8D3C' :
                        d > 50 ? '#FEB24C' :
                            d > 10 ? '#FED976' :
                                '#FFEDA0';

}

function style(feature) {//json的每个属性会执行此函数
    return {
        fillColor: getColor(feature.properties.density),//
        weight: 2,
        opacity: 1,
        color: 'white',
        dashArray: '3',
        fillOpacity: 0.7
    };
}

function highlightFeature(e) {//当鼠标拂过时高亮显示
    var layer = e.target;

    layer.setStyle({
        weight: 5,
        color: '#666',
        dashArray: '',
        fillOpacity: 0.7
    });

    if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
        layer.bringToFront();
    }
    info.update(layer.feature.properties);
}

function resetHighlight(e) {//当鼠标退出后reset
    geojson.resetStyle(e.target);//  geojson要先定义
    info.update();
}

function onEachFeature(feature, layer) {//遍历每一个数据，也就是为每一个地点加上监听器
    layer.on({
        mouseover: highlightFeature,
        mouseout: resetHighlight,
        //click: zoomToFeature
    });
}

geojson = L.geoJson(chinaData, {
    style: style,
    onEachFeature: onEachFeature
});
info = L.control({position: 'bottomleft'});//添加一个组件，也可以使用自己定义的组件，设置监听事件，使用float属性 或者position:absolute

info.onAdd = function (mymap) {
    this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
    this.update();
    return this._div;
};

// method that we will use to update the control based on feature properties passed
info.update = function (props) {
    this._div.innerHTML = (props ?
        '<b>' + props.name + '</b><br />' + props.density + ' people / mi<sup>2</sup>'
        : '点击省份');
};

info.addTo(map);//加入图标

legend = L.control({position: 'bottomright'});

legend.onAdd = function (map) {//onAdd函数向其中添加组件

    var div = L.DomUtil.create('div', 'info legend'),
        grades = [0, 10, 50, 100, 200, 500, 1000, 3000],
        labels = [];

    // loop through our density intervals and generate a label with a colored square for each interval
    for (var i = 0; i < grades.length; i++) {
        div.innerHTML +=
            '<i style="background:' + getColor(grades[i] + 1) + '"></i> ' +
            grades[i] + (grades[i + 1] ? '–' + grades[i + 1] + '<br>' : '+');
    }

    return div;
};
legend.addTo(map);//加入显示比例尺
//隐藏人口密度的图例
$('.info').hide();
// });
// $.post("http://"+n2.billId,{"kind_code":"01","product_code":"0001","id":id},function (data) {
//     centerCoordinate[0]=data.lat;
//     centerCoordinate[1]=data.lon;
//     map.setView(centerCoordinate);
//     console.log(centerCoordinate);
//     console.log(data)
// });






//找到切换地图种类的dom元素
var map_2D = document.querySelector(".map_2D");
var weixing = document.querySelector(".weixing");
var renkoumidu = document.querySelector(".renkoumidu");
var map_DEM = document.querySelector(".DEM");

//清除所有的图层
function clearAll() {
    if (map.hasLayer(geojson)) map.removeLayer(geojson);
    if (map.hasLayer(ter_c)) map.removeLayer(ter_c);
    if (map.hasLayer(img_c)) map.removeLayer(img_c);
    if (map.hasLayer(vec_c)) map.removeLayer(vec_c);

//            map.removeLayer(cva_c);
//            map.removeLayer(boundary);
}

map_2D.addEventListener("tap", function () {
    clearAll();
    map.addLayer(vec_c);
    $('.info').hide();
    $('.leaflet-popup').remove();
});
weixing.addEventListener("tap", function () {
    clearAll();
    map.addLayer(img_c);
//            map.addLayer(cva_c);
//            map.addLayer(boundary);
    $('.info').hide();
    $('.leaflet-popup').remove();
});
renkoumidu.addEventListener("tap", function () {
    clearAll();
    map.addLayer(vec_c);
//            map.addLayer(cva_c);
//            map.addLayer(boundary);
    if (geojson) map.addLayer(geojson);
    $('.info').show();
    // map.setView([38.4, 100.6], 3);
    $('.leaflet-popup').remove();
});
map_DEM.addEventListener("tap", function () {
    clearAll();
    map.addLayer(ter_c);
//            map.addLayer(cva_c);
//            map.addLayer(boundary);
    $('.leaflet-popup').remove();
    $('.info').hide();
});
var select1 = document.querySelector(".select1");
var select2 = document.querySelector(".select2");
var select3 = document.querySelector(".select3");
var select4 = document.querySelector(".select4");
var state1 = false;
select1.addEventListener("tap", function (e) {
//  map.removeLayer(totalLayer1);
//  map.removeLayer(totalLayer);
//  map.addLayer(totalLayer1);
//  map.addLayer(totalLayer);
    $('.echartssymbol').hide();
    if ($('#item1mobile').hasClass('mui-active')) {
        return;
    } else {
        $('#bg').prependTo('.bg-content');
//      map.setView([38.11, 99.13], 4);
        $('.leaflet-echart-icon').hide();
        $('.leaflet-popup').remove();
        state1 = false;
    }  
    var newEle = $('#GongnengfenleiBtn');
    $('#GongnengfenleiBtn').remove();
    $('#ShousunfenleiBtn').before(newEle);
});
select2.addEventListener("tap", function (e) {
    $('.echartssymbol').show();
    if ($('#item2mobile').hasClass('mui-active')) {
        return;
    } else {
        $('#bg').prependTo('.bg01-content');
//      map.removeLayer(totalLayer1);
//      map.removeLayer(totalLayer);
        clearAll();
        map.addLayer(vec_c);
//                map.addLayer(cva_c);
//                map.addLayer(boundary);
        map.addLayer(pictures);
//      map.setView([38.11, 99.13], 4);
        $('.leaflet-echart-icon').show();
        $('.info').hide();
        $('.leaflet-popup').remove();
        state1 = true;
    }
//        var map1 =new L.map('bg01', {
//            center: [29.60553, 108.17871],
//            zoom: 2
//        });
//        var vec_c1=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
//            attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a>contributors'
//        }).addTo(map1);
//        map1.addLayer(vec_c1);
});
select3.addEventListener("tap", function (e) {
//	map.removeLayer(totalLayer1);
//  map.removeLayer(totalLayer);
//  map.addLayer(totalLayer1);
//  map.addLayer(totalLayer);
    $('.echartssymbol').hide();
    if ($('#item3mobile').hasClass('mui-active')) {
        return;
    } else {
        $('#bg').prependTo('.bg02-content');
//      map.removeLayer(totalLayer1);
//      map.removeLayer(totalLayer);
        clearAll();
        map.addLayer(vec_c);
//                map.addLayer(cva_c);
//                map.addLayer(boundary);
//       map.setView([38.11, 99.13], 4);
        $('.info').hide();
        $('.leaflet-echart-icon').hide();
        $('.leaflet-popup').remove();
        state1 = false;
    }
    var newEle = $('#GongnengfenleiBtn');
    $('#GongnengfenleiBtn').remove();
    $('#LishidizhenBtn1').before(newEle);
});
select4.addEventListener("tap", function (e) {
    $('.info').hide();
    $('.leaflet-popup').remove();
    state1 = false;
});
//.以marker形式添加Echarts在map
//var pictures = L.marker([37.93553, 78.84888], {
//  icon: L.divIcon({
//      className: 'leaflet-echart-icon',
//      iconSize: [160, 160],
//      html: '<div id="marker" style="width: 160px; height: 160px; position: relative; background-color: transparent;"></div>'
//  })
//}).addTo(map);
// 基于准备好的dom，初始化echarts实例
//var myChart = echarts.init(document.getElementById('marker'));
// 指定图表的配置项和数据
//var option = {
//  tooltip: {
//      trigger: 'item',
//      formatter: "{a} <br/>{b}: {c} ({d}%)"
//  },
//  series: [{
//      name: '倒损评估',
//      type: 'pie',
//      radius: ['20', '50'],
//      avoidLabelOverlap: false,
//      label: {
//          normal: {
//              show: false,
//              position: 'center'
//          },
//          emphasis: {
//              show: false,
//              textStyle: {
//                  fontSize: '18',
//                  fontWeight: 'bold'
//              }
//          }
//      },
//      labelLine: {
//          normal: {
//              show: false
//          }
//      },
//      data: [{
//          value: 1,
//          name: '倒损(间)'
//      }, {
//          value: 2,
//          name: '严重损坏(间)'
//      }, {
//          value: 3,
//          name: '一般损坏(间)'
//      }]
//  }]
//};
// 指定的数据2
//var option1 = {
//  tooltip: {
//      trigger: 'item',
//      formatter: "{a} <br/>{b} : {c} ({d}%)"
//  },
//  series: [
//      {
//          name: '地方上报',
//          type: 'pie',
//          radius: '55%',
//          center: ['50%', '60%'],
//          data: [
//              {value: 135, name: '倒损(间)'},
//              {value: 310, name: '严重损坏(间)'},
//              {value: 234, name: '一般损坏(间)'}
//          ],
//          itemStyle: {
//              emphasis: {
//              	show:false,
//                  shadowBlur: 10,
//                  shadowOffsetX: 0,
//                  shadowColor: 'rgba(0, 0, 0, 0.5)'
//              }
//          }
//      }
//  ]
//};
//加载图例
//var echartsSymbol = L.control({position: 'bottomright'});
//echartsSymbol.onAdd = function (map) {//onAdd函数向其中添加组件

//  var div = L.DomUtil.create('div', 'echartssymbol'),
//      echartscolor = ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];

    // loop through our density intervals and generate a label with a colored square for each interval
//  for (var i = 0; i < option.series[0].data.length; i++) {
//      div.innerHTML +=
//          '<i style="background:' + echartscolor[i] + '"></i> ' +
//          option.series[0].data[i].name + ':<span>' + option.series[0].data[i].value + '</span><br>';
//  }
//  return div;
//};
//echartsSymbol.addTo(map);//加入显示比例尺
// 使用刚指定的配置项和数据显示图表。
//myChart.setOption(option);
//图层
//$('.leaflet-echart-icon').hide();
//$('.echartssymbol').hide();
//var state = true;//echarts类型切换的哨兵值
//点击评论事件绑定
//document.querySelector('.btn-type2').addEventListener("touchstart", function (e) {
//  state = true;
//  document.querySelector('.distroy-house').innerHTML = '房屋倒损评估';
//  if (state) {
//      $('#img-btn-type2').css('backgroundPosition', '-80px -120px');
//      $('#img-btn-type3').css('backgroundPosition', '-120px -80px');
//      myChart.setOption(option);
//     
//  }
//  e.stopPropagation();
//});
//点击报告事件绑定
//document.querySelector('.btn-type3').addEventListener("touchstart", function (e) {
//  state = false;
//  document.querySelector('.distroy-house').innerHTML = '房屋倒损地方上报';
//  if (!state) {
//      $('#img-btn-type2').css('backgroundPosition', '-80px -80px');
//      $('#img-btn-type3').css('backgroundPosition', '-120px -120px');
//      myChart.setOption(option1);
//      $('.echartssymbol').children('span').each(function (index) {
//          $(this).html(option1.series[0].data[index].value)
//      });
//  }
//  e.stopPropagation();
//});
//监听地图层级的改变，echarts图表的消失和隐藏
//map.on('zoomend', function (e) {
//  if (map.getZoom() > 3 && state1) {
//      $('.leaflet-echart-icon').show();
//  } else {
//      $('.leaflet-echart-icon').hide();
//  }
//  if (!state1) {
//      $('.leaflet-echart-icon').hide();
//  }
////          console.log(map.getZoom());
//});

//usgs   paper    切换
var usBtn = document.getElementById('us');
var paBtn = document.getElementById('pa');
var usCont = document.getElementById('usgu');
var paCont = document.getElementById('paper');
usBtn.addEventListener('tap', function (event) {
    usBtn.classList.add("active");
    paBtn.classList.remove("active");

    usCont.classList.add("active", "in");
    paCont.classList.remove("active", "in");

}, false);

paBtn.addEventListener('tap', function (event) {

    mui.previewImage();
    paBtn.classList.add("active");
    usBtn.classList.remove("active");

    paCont.classList.add("active", "in");
    usCont.classList.remove("active", "in");

}, false);

